<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
if(!isset($_SESSION['adminuserid']))
{
	header("location:index.php?msg=logfirst");
	die();
}					
//echo $_SERVER['HTTP_USER_AGENT'];
if(isset($_REQUEST['status']) && trim($_REQUEST['status']) != "")
{
	$stid = $_REQUEST['status'];
	$stid=explode("@",$stid);
	$insert="INSERT INTO `tblorderstatushistory` (`intorderid`,`intorderstatusid`,`dtdateadded`,`intcustomernotify`,`varcomments`,`varedite`) VALUES (".$stid[0].",".$stid[1].",NOW(),0,'Order Status Changed','Auto')";
	$sql=$obj_db->insert($insert);	
	$query = "UPDATE `tblorders` SET `intcurrentorderstatus`='".$stid[1]."' WHERE `intid`=".$stid[0];
	$sql=$obj_db->edit($query);	
	header("location:customerreport.php?msg=statusupdate");
	die();
}

?>
<?php include("inc/header.php");?>
<body>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class="middlebackground">
  <tr>
    <td valign="top" align="center"><?php include(INC."top.inc.php");?></td>
  </tr>
  <tr valign="top">
    <td align="center">
	<br />
	<table width="80%" border="0" align="center" class="border">
     
	  <tr class="bg1">
        <td colspan="5" align="left"><strong>Customer Order Report ... </strong></td>
      </tr>
      <tr align="center" class="tblbg3">
	  	<td><strong>Order ID</strong></td>
        <td><strong>Customer Name</strong></td>
        <td><strong>Product Name</strong></td>
        <td><strong>Status</strong></td>
		<td><strong>Change Status</strong></td>
      </tr>
	  
<?php
		/**************************************
				PAGING CODE START
		**************************************/
			//$rowperpage=23;
			$tablename="tblorders";
			$per_page_keywords= "";
			$per_page_sorts= "";
		
			include("system/paging.inc.php");

		/**************************************
				PAGING CODE ENDING
		**************************************/
		
		$sql_select = "SELECT * from  ".$tablename."		
		Limit ".($page_no*$row_per_page).",".$row_per_page;
		$sql = $obj_db->select($sql_select);
	
		if(count($sql)>0)
		{
			for($j=0;$j<count($sql);$j++)
			 { 
				$screen_id=$sql[$j]['intid'];
?>
		<form name="frm<?php echo $j;?>" method="post" action="">
	    <tr align="center" class="<?php echo ($j%2==0)?"Hrnormal":"Hralter"; ?>" onMouseOver="this.className='Hrhover';" onMouseOut="this.className='<?php echo ($j%2==0)?"Hrnormal":"Hralter"; ?>';">
		<td><?php echo $sql[$j]['intid']; ?></td>
        <td><?php echo $sql[$j]['varcustomername']; ?></td>
		<td><?php
				$sql_select3 = "select * from `tblorderproducts` where `intorderid`=$screen_id"; 
				$sql3 = $obj_db->select($sql_select3);
				if(count($sql3)>0)
				{		
					for($pd=0;$pd<count($sql3);$pd++) { 
						echo $sql3[$pd]['varproductname']." (Code: ".$sql3[$pd]['intproductid'].")<br />";	
					}
				}
			?>
		</td>
		<td>
			<?php		
				$sql_select2 = "select *
				from `tblorderstatus` 
				where  intid=".$sql[$j]['intcurrentorderstatus']; 
				$sql2 = $obj_db->select($sql_select2);
				if($sql2)
				{	 
					echo $sql2[0]['varstatus'];		
				}
			?>
		</td>
		        
		<td>		
		  <select name="status" id="status" onChange="this.form.submit();">
		   <option>Select Status</option>
            		<?php
						//$sta = $_REQUEST['status'];						
						$sqlt="select * from `tblorderstatus`";
						$resman = $obj_db->select($sqlt);
						if(count($resman)>0)
						{
							for($m=0;$m<count($resman);$m++)
							{								
					?>           
            <option value="<?php echo $screen_id."@".$resman[$m]['intid'];?>"><?php echo $resman[$m]['varstatus'];?></option>
            		<?php
							}
						}
					?>
          </select>		
		</td>
      </tr>
	  </form>
	  
	  <?php 
	  	 }
	   } 
	  ?>
	  
      <tr>       
        <td>&nbsp;</td>
        <td>&nbsp;</td>
		 <td>&nbsp;</td>
		 <td>&nbsp;</td>
      </tr>
	  
      <tr align="center">
        <td colspan="4"><?php pagindet_atbotttom_page($div_page_no,$page_no,$req_querystr,$total_db_rec,$row_per_page); ?></td>
        </tr>
</table>
	
	
	</td>
  </tr>
  <tr>
    <td align="center"><?php include(INC."bottom.php");?></td>
  </tr>
</table>

</body>
</html>
